import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

/**
 * Generated class for the NewsDetailPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-news-detail',
  templateUrl: 'news-detail.html',
})
export class NewsDetailPage {
  selectedItem:any;
  imgs: any; 
  action:any;
  constructor(public navCtrl: NavController, public navParams: NavParams) {
    //参数传值 获取父视图穿过来的值
    this.selectedItem = this.navParams.get('params');
    //回传值到父视图,从A页面获取的'action'参数不是一般的参数 而是一个promise方法 所以我们可以直接赋值之后使用acion()方法进行传参，当然我们的then()是为了页面A接收到数据或者报错之后的处理

    /** 
    this.action = this.navParams.get('action');
    let sonData = 'Iam son data';
    this.action(sonData).then(result=>{
      this.navCtrl.pop();
    }, err=>{
      console.log(err);
    })
    if (this.selectedItem.SmallImages) {          
      this.imgs = this.selectedItem.SmallImages;
    }
    */

  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad NewsDetailPage');
  }

}
